package com.tongda.menu.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CheckedTextView;
import android.widget.TextView;
import android.widget.Toast;

import com.tongda.core.vo.DishesSetDishes;
import com.tongda.core.vo.DishesSetDishesReplace;
import com.tongda.menu.R;

public class DsReplacesAdapter extends BaseAdapter{
	private DishesSetDishes dsDishe;
	private List<DishesSetDishesReplace> datas;
	private Context context;
	
	
	public DsReplacesAdapter(DishesSetDishes diDishe,List<DishesSetDishesReplace> datas, Context context) {
		super();
		this.dsDishe = diDishe;
		this.datas = datas;
		this.context = context;
	}
	@Override
	public int getCount() {
		return datas.size();
	}
	@Override
	public Object getItem(int position) {
		return datas.get(position);
	}
	@Override
	public long getItemId(int position) {
		return position;
	}
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if(convertView==null){
			holder = new Holder();
			convertView = View.inflate(context, R.layout.adapter_item_dsreplaces, null);
			holder.dsReplaceTv = (TextView)convertView.findViewById(R.id.adapter_item_dsreplace);
			convertView.setTag(holder);
		}else{
			holder = (Holder) convertView.getTag();
		}
		
		DishesSetDishesReplace dsReplace = datas.get(position);
		holder.dsReplaceTv.setText(dsReplace.getDishesName()+"x"+dsReplace.getDsUnitNum()+dsReplace.getDishesUnitName());
		
		return convertView;
	}
	
	public class Holder{
		TextView dsReplaceTv;
	}
}
